#include "ejskillset.h"

#include <QGroupBox>
#include <QHBoxLayout>
#include <QGridLayout>



EJSkillSet::EJSkillSet(QWidget *parent) : QMainWindow(parent)
{
    auto central = new QWidget(this);
    setCentralWidget(central);
    central->setStyleSheet("QLabel{color:#E1E1E1; border:none;} QGroupBox{color:#888888; border-color:#000000}");

    auto hLayout = new QHBoxLayout(central);
    central->setLayout(hLayout);

    auto skillBox  = new QGroupBox(tr("技能设置"), this);
    auto statusBox = new QGroupBox(tr("状态设置"), this);

    hLayout->addWidget(skillBox);
    hLayout->addWidget(statusBox); /*15*/

    hLayout->setStretchFactor(skillBox, 1);
    hLayout->setStretchFactor(statusBox, 1);

    auto skillLayout = new QGridLayout(skillBox);

    skillLayout->addWidget(new QLabel(tr("技能列表"), this), 0, 0, 1, 1);
    skillLayout->addWidget(m_skillList = new QListWidget(this), 0, 0, 12, 1);

    skillLayout->addWidget(new QLabel(tr("技能名称"), this), 0, 1, 1, 1);
    skillLayout->addWidget(new QLabel(tr("前置技能"), this), 1, 1, 1, 1);
    skillLayout->addWidget(new QLabel(tr("前置等级"), this), 2, 1, 1, 1);
    skillLayout->addWidget(new QLabel(tr("职业限制"), this), 3, 1, 1, 1);
    skillLayout->addWidget(new QLabel(tr("技能类型"), this), 4, 1, 1, 1);
    skillLayout->addWidget(new QLabel(tr("是否被动"), this), 5, 1, 1, 1);
    skillLayout->addWidget(new QLabel(tr("是否群攻"), this), 6, 1, 1, 1);
    skillLayout->addWidget(new QLabel(tr("解除状态"), this), 7, 1, 1, 1);
    skillLayout->addWidget(new QLabel(tr("目标类型"), this), 8, 1, 1, 1);
    skillLayout->addWidget(new QLabel(tr("恢复属性"), this), 9, 1, 1, 1);
    skillLayout->addWidget(new QLabel(tr("技能描述"), this), 10, 1, 1, 1);

    skillLayout->addWidget(new QLabel(tr("技能图标"), this), 0, 3, 3, 1);
    skillLayout->addWidget(new QLabel(tr("技能音效"), this), 3, 3, 1, 1);
    skillLayout->addWidget(new QLabel(tr("技能消耗"), this), 4, 3, 1, 1);
    skillLayout->addWidget(new QLabel(tr("伤害计算"), this), 5, 3, 1, 1);
    skillLayout->addWidget(new QLabel(tr("攻击数量"), this), 6, 3, 1, 1);
    skillLayout->addWidget(new QLabel(tr("附加状态"), this), 7, 3, 1, 1);
    skillLayout->addWidget(new QLabel(tr("攻击范围"), this), 8, 3, 1, 1);
    skillLayout->addWidget(new QLabel(tr("恢复数值"), this), 9, 3, 1, 1);

    skillLayout->addWidget(m_skillName     = new QComboBox(this), 0, 2, 1, 1);
    skillLayout->addWidget(m_preSkill      = new QComboBox(this), 1, 2, 1, 1);
    skillLayout->addWidget(m_preSkillLevel = new QComboBox(this), 2, 2, 1, 1);
    skillLayout->addWidget(m_carLimit      = new QComboBox(this), 3, 2, 1, 1);
    skillLayout->addWidget(m_skillType     = new QComboBox(this), 4, 2, 1, 1);
    skillLayout->addWidget(m_passvie       = new QComboBox(this), 5, 2, 1, 1);
    skillLayout->addWidget(m_multiTarget   = new QComboBox(this), 6, 2, 1, 1);
    skillLayout->addWidget(m_revokStatus   = new QComboBox(this), 7, 2, 1, 1);
    skillLayout->addWidget(m_targetType    = new QComboBox(this), 8, 2, 1, 1);
    skillLayout->addWidget(m_skillPic       = new QLabel("", this), 0, 4, 3, 1);
    skillLayout->addWidget(m_skillSound     = new QLineEdit(this), 3, 4, 1, 1);
    skillLayout->addWidget(m_skillExpand    = new QLineEdit(this), 4, 4, 1, 1);
    skillLayout->addWidget(m_skillHurtAglo  = new QLineEdit(this), 5, 4, 1, 1);
    skillLayout->addWidget(m_skillAttackNum = new QLineEdit(this), 6, 4, 1, 1);
    skillLayout->addWidget(m_attachStatus   = new QLineEdit(this), 7, 4, 1, 1);
    skillLayout->addWidget(m_attackRange    = new QLineEdit(this), 8, 4, 1, 1);

    m_skillPic->setPixmap(QPixmap("://res/png/backgroup.png"));
    skillBox->setLayout(skillLayout);

    auto statusLayout = new QGridLayout(statusBox);

    statusLayout->addWidget(new QLabel(tr("状态列表"), this), 0, 0, 1, 1);
    statusLayout->addWidget(m_statusList = new QListWidget(this), 0, 0, 12, 1);
    statusLayout->addWidget(new QLabel(tr("状态名称"), this), 0, 1, 1, 1);
    statusLayout->addWidget(new QLabel(tr("持续回合"), this), 1, 1, 1, 1);
    statusLayout->addWidget(new QLabel(tr("是否叠加"), this), 2, 1, 1, 1);
    statusLayout->addWidget(new QLabel(tr("增益\\损益"), this), 3, 1, 1, 1);
    statusLayout->addWidget(new QLabel(tr("属性"), this), 4, 1, 1, 1);
    statusLayout->addWidget(new QLabel(tr("行动限制"), this), 5, 1, 1, 1);
    statusLayout->addWidget(new QLabel(tr("状态动画"), this), 6, 1, 1, 1);
    statusLayout->addWidget(new QLabel(tr("动画层级"), this), 7, 1, 1, 1);
    statusLayout->addWidget(new QLabel(tr("状态描述"), this), 8, 1, 1, 1);
    statusLayout->addWidget(new QLabel(tr("状态脚本"), this), 9, 1, 1, 1);

    statusLayout->addWidget(m_statusName      = new QComboBox(this), 0, 2, 1, 1);
    statusLayout->addWidget(m_statusComtinue  = new QComboBox(this), 1, 2, 1, 1);
    statusLayout->addWidget(m_statusOverlyed  = new QComboBox(this), 2, 2, 1, 1);
    statusLayout->addWidget(m_statusGain      = new QComboBox(this), 3, 2, 1, 1);
    statusLayout->addWidget(m_statusAttr      = new QComboBox(this), 4, 2, 1, 1);
    statusLayout->addWidget(m_statusAction    = new QComboBox(this), 5, 2, 1, 1);
    statusLayout->addWidget(m_statusAnimation = new QComboBox(this), 6, 2, 1, 1);
    statusLayout->addWidget(m_statusAniOder   = new QComboBox(this), 7, 2, 1, 1);

    statusLayout->addWidget(m_animation       = new EJAnimationWidget(this), 0, 3, 12, 4);

    statusLayout->setColumnStretch(0, 1);
    statusLayout->setColumnStretch(1, 1);
    statusLayout->setColumnStretch(2, 1);
    statusLayout->setColumnStretch(3, 2);

    statusBox->setLayout(statusLayout);

    /**
     * @brief animation test
     */
    EJAnimation *animation = new EJAnimation;
    animation->setFps(8);
    for (int i = 0; i < 12; i++)
    {
        QString name = QString().sprintf("animation/02C946FF%04d.png", i);
        animation->addFrame(new AnimationFrame(QPixmap(name), QPoint(131, 147)));
    }


    m_animation->setAni(animation);


}
